
package com.stchou.superwidget.imagetextviewbutton;

import com.stchou.superwidget.R;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ImageTextViewButton extends LinearLayout
{

    private ImageView iv;
    private TextView tv;

    public ImageTextViewButton(Context context)
    {
        this(context, null);
    }

    public ImageTextViewButton(Context context, AttributeSet attrs)
    {
        super(context, attrs);
        initViews(context, attrs);
    }

    private void initViews(Context context, AttributeSet attrs)
    {

//        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ImageTextViewButton);
//        int direction = typedArray.getIndex(R.attr.image_direction);
//        switch (direction)
//        {
//            case 0:
//                break;
//        }
        // 导入布局
        LayoutInflater.from(context).inflate(R.layout.imagetext_button_down, this, true);
        iv = (ImageView)findViewById(R.id.iv);
        tv = (TextView)findViewById(R.id.tv);

   //     typedArray.recycle();
    }

    /**
     * 设置图片资源
     */
    public void setImageResource(int resId)
    {
        iv.setImageResource(resId);
    }

    /**
     * 设置显示的文字
     */
    public void setTextViewText(String text)
    {
        tv.setText(text);
    }

    public void setTextViewText(int rid)
    {
        tv.setText(rid);
    }
}
